package com.project.controller;

import com.project.bean.GradeBean;
import com.project.service.IGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("grade")
@Api(tags = "用户权限控制器")
public class GradeController {
    @Autowired
    private IGradeService service;

    @RequiresPermissions("grade:user")
    @RequestMapping("findAllGrade")
    @ApiOperation(value = "查看所有权限", notes = "查看所有权限")
    public List<GradeBean> findGradeAll() {
        return service.findAllGrade();
    }

    @RequiresPermissions("grade:user")
    @RequestMapping("findGradeListByUserId")
    @ApiOperation(value = "根据用户id查看他所拥有的权限", notes = "根据用户id查看他所拥有的权限")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "userId", value = "用户id")
    })
    public List<GradeBean> findGradeListByUserId(Integer userId){
        return service.findGradeListByUserId(userId);
    }
}
